<?php
/**
 * Admin Login View - LaFabbrica.org
 * 
 * @author     luigi.pastore (gigi@la-fabbrica.org)
 * @created    19-apr-2011
 * @package    LaFabbrica
 * @copyright  Copyright (c) 2011 Luigi Pastore
 */
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
	<link rel="shortcut icon" href="logo.ico" type="image/x-icon" />
	<link rel="icon" href="logo.ico" type="image/x-icon" />
	<title>La Fabbrica - Admin</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<!-- CSS -->
	<link rel="stylesheet" href="/css/admin/structure.css" type="text/css" />
	<link rel="stylesheet" href="/css/admin/form.css" type="text/css" />
	<link rel="stylesheet" href="/css/admin/theme.css" type="text/css" />
	<link rel="stylesheet" href="/css/admin/navigation.css" type="text/css" />
	<link rel="stylesheet" href="/css/admin/jquery-ui-1.8.11.custom.css" type="text/css" />
	<link rel="stylesheet" href="/css/admin/pagination.css" type="text/css" />
	<!--	<link rel="stylesheet" href="/css/admin/smartpaginator.css" type="text/css" />-->
	<!-- JavaScript -->
	<script type="text/javascript" src="/js/jquery-1.5.1.min.js"></script>
	<!--<script type="text/javascript" src="/js/fab.js"></script>
	<script type="text/javascript" src="/js/cufon-yui.js"></script>
	<script type="text/javascript" src="/js/cufon-marketingscript.js"></script>
	<script type="text/javascript" src="/js/script.js"></script>-->
	<!--	<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.8/jquery.validate.js"></script>-->
	<!-- required plugins -->
	<script type="text/javascript" src="/js/jquery-ui-1.8.11.custom.min.js"></script>
	<script type="text/javascript" src="/js/jquery.validate.min.js"></script>
	<script type="text/javascript" src="/js/jquery.pagination.js"></script>
<!--	<script type="text/javascript" src="/js/jquery.smartpaginator.js"></script>-->

	<!--[if IE]><script type="text/javascript" src="/js/jquery.bgiframe.js"></script><![endif]-->
    </head>
    <body id="public">

	<script type="text/javascript">
	    <!--
	    $(document).ready(function() {
		$.validator.addMethod(
		"regex",
		function(value, element, regexp) {
		    return regexp.test(value);
		}
	    );
	
		$("#loginForm").validate({
		    //	    invalidHandler: function(e, validator) {
		    //		var errors = validator.numberOfInvalids();
		    //		if (errors) {
		    //		    var message = errors == 1
		    //			? 'You missed 1 field. It has been highlighted below'
		    //		    : 'You missed ' + errors + ' fields.  They have been highlighted below';
		    //		    $("div.error span").html(message);
		    //		    $("div.error").show();
		    //		} else {
		    //		    $("div.error").hide();
		    //		}
		    //	    },
		    // Assegna classe 'error' al <li> dell'elemento invalido
		    errorPlacement: function(error, element) {
			console.log(element);
			element.parent("div").parent("li").addClass("error");
			error.appendTo( element.parent("div"));
		    },
		    submitHandler: function(form) {
			// do other stuff for a valid form
			form.submit();
		    },	    
		    errorElement: "p",
		    rules: {
			email:{
			    required: true,
			    email: true
			},
			password:{
			    required: true,
			    regex: /^[0-9a-zA-Z.]{4,}$/i
			}
		    },
		    messages: {
			password: {
			    required: "<?php echo ERR_EMPTY ?>",
			    regex: "<?php echo ERR_PASSWORD ?>"
			},
			email: {
			    required: "<?php echo ERR_EMPTY ?>",
			    email: "<?php echo ERR_EMAIL ?>"
			}
		    },
		    debug:true
		});

	    });
	    //-->
	</script>
	<div id="container" class="login">
	    <form class="cmxform" id="loginForm" method="post" action="/admin/index">
		<ul>
		    <li class="section">
			<h3>Login</h3>
		    </li>	    
		    <li id="" class="<?php echo $this->errorMsg['userAuth'] ? 'error' : ''?>">
			<label class="desc <?php echo $this->errorMsg['userAuth'] ? 'error' : ''?>">Email</label>
			<div>
			    <input id="email" name="email" class="field text large email required" type="text" maxlength="255" value=""/> 
			</div>
			<p class="error" style="<?php echo $this->errorMsg['userAuth'] ? 'display:block' : ''?>"><?php echo $this->errorMsg['userAuth']?></p>
		    </li>
		    <li class="">
			<label class="desc">Password</label>
			<div>
			    <input id="password" name="password" class="field text large required" type="password" maxlength="255" value=""/> 
			</div>
			<p class="error"><?php echo $errorMsg['password'] ?></p>
		    </li>
		    <!--	    <li class="error ">
		<label class="desc">
		Your Email Address
					<span id="req_0" class="req">*</span>
		</label>
		<div>
					<input id="Field0" name="Field0" type="email" class="field text large" value="" maxlength="255" tabindex="1" onkeyup="handleInput(this);" onchange="handleInput(this);"  /> 
		</div>
				    <p class="error">This field is required. Please enter a value.</p>
	    </li>-->
		    <li class="section">
			<h3>&nbsp;</h3>
		    </li>
		    <li class="buttons">
			<input class="submit" id="conferma" name="conferma" type="submit" value="conferma" />
		    </li>
		</ul>
	    </form>
	</div><!--container-->
	<img id="bottom" class="login" src="/images/admin/bottom.png" alt="" />
    </body>
</html>
